<template>
	<view class="cancellation">
		<view class="c-user">
			<text>当前用户</text>
			<view class="c-user-account">{{phone}}</view>
		</view>

		<view class="c-tips">
			<view class="c-tips-title">温馨提示</view>
			<view class="c-tips-content">请确认你的账号中是否存在未使用的兑换卡、待收货的物品、存在尚未完结的服务或订单等，操作完成后可注销账户。</view>
		</view>

		<button class="c-btn-cannellation" @tap="onShowCanncellationDialog">注销账号</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phone : "404",
				userInfo : null,
			}
		},
		mounted() {
			this.getUserInfo()
		},
		methods: {
			async getUserInfo(){
				this.userInfo = await uni.getStorageSync("userInfo")
				this.phone = await uni.getStorageSync("userInfo").userMobile
			},
			/* 打开注销账号弹窗 */
			onShowCanncellationDialog() {
				if(this.userInfo.deleteStatus === 2){
					uni.showToast({
						title: "已申请账号注销,请耐心等待!",
						icon: 'none',
						duration: 1500
					})
					return
				}
				uni.showModal({
					title: "确认注销账号",
					content: "请知悉，账号注销后将不可恢复，该账号内所有的交易记录将被清空，您的身份信息、账号信息、兑换卡等将被清空且无法回复。",
					cancelText: "再想想",
					confirmText: "确认注销",
					confirmColor: "#ee0a24",
					success: function(res) {
						if (res.confirm) {
							/* 确认 */
							uni.navigateTo({
								url: '/pages/account-login/account-login?isCancellation=true'
							})
						} else {
							/* 取消 */
							console.log("取消");
						}
					}
				})
			},
		}
	}
</script>

<style>
	@import "./cancellation-page.css";
</style>
